<%--
  Created by IntelliJ IDEA.
  User: czl
  Date: 2021/7/1
  Time: 13:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>
        管理员修改
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="css/main.css" media="all">
    <script type="text/javascript" src="lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="css/bootstrap.css">

</head>

<body>
<div class="x-body">

    <xblock>
        <button class="layui-btn" >
            管理员修改
        </button>
    </xblock>
    <blockquote class="layui-elem-quote">
        <input type="hidden" name="id" value="8">
        <div >
            <img src="./images/tx.jpg" class="layui-circle" style="width:50px;height:50px;float:left" id="pimages" name="pimages"   alt="个人头像" >
            <input id="avatar"   name="image" required="" type="hidden" value="./images/tx.jpg" >
            <dl style="margin-left:80px; color:#019688">
                <dt><span >${user.userName}</span> <span ></span></dt>
                <dd style="margin-left:0">这家伙很懒，什么也没有留下</dd>
            </dl>
        </div>
    </blockquote>
    <form action="power/update" method="post" id="update_admin">
        <input type="hidden"  name="userId" id="userId" value="${user.userId}" />
        用户账号:   <input name="userAccount" id="userAccount"  type="text" value="${user.userAccount}"   class="layui-input" >
        <hr class="hr15">
        用户密码:   <input name="userPwd" id="userPwd"  type="text" value="${user.userPwd}"   class="layui-input" >
        <hr class="hr15">
        用户名:   <input name="userName" id="userName"  type="text" value="${user.userName}"    class="layui-input" >
        <hr class="hr15">
        证件类型:   <select class="form-control" id="idType.typeId"
                        name="idType.typeId" >
        <option value="${user.idType.typeId}">
            ${user.idType.typeName}
        </option>
        <c:forEach items="${zhengjianList}" var="z">
            <option value="${z.typeId}">
                    ${z.typeName}
            </option>
        </c:forEach>
    </select><hr class="hr15">
        证件号码:   <input name="idNumber" id="idNumber"  type="text" value="${user.idNumber}"   class="layui-input" >
        <hr class="hr15">
        性别类型:   <select class="form-control" id="sexType.typeId"
                        name="sexType.typeId" >
        <option value="${user.sexType.typeId}">
            ${user.sexType.typeName}
        </option>
        <c:forEach items="${xingbieList}" var="x">
            <option value="${x.typeId}">
                    ${x.typeName}
            </option>
        </c:forEach>
    </select><hr class="hr15">
        用户电话:   <input name="userTel" id="userTel"  type="text" value="${user.userTel}"    class="layui-input" >
        <hr class="hr15">
        乘客类型:  <select class="form-control" id="passengerType.typeId"
                       name="passengerType.typeId" >
        <option value="${user.passengerType.typeId}">
            ${user.passengerType.typeName}
        </option>
        <c:forEach items="${chengkeList}" var="c">
            <option value="${c.typeId}">
                  ${c.typeName}
            </option>
        </c:forEach>
    </select><hr class="hr15">
        注册时间:   <input name="registerTime" id="registerTime"  type="text" value="${user.registerTime}" disabled="disabled"  class="layui-input" >
        <hr class="hr15">
        联系人姓名:   <input name="contactName" id="contactName"  type="text" value="${user.contactName}"   class="layui-input" >
        <hr class="hr15">
        联系人电话:   <input name="contactTle" id="contactTle"  type="text" value="${user.contactTle}"   class="layui-input" >
        <hr class="hr15">
        用户类型：<select class="form-control" id="userType.typeId"
                     name="userType.typeId" disabled="disabled">
        <option value="${user.userType.typeId}">
            ${user.userType.typeName}
        </option>
        <c:forEach items="${types}" var="t">
            <option value="${t.typeId}">
                      ${t.typeName}
            </option>
        </c:forEach>
    </select>
        <hr class="hr15">
        <div align="center">  <button class="layui-btn" type="button" id="" lay-filter="add" lay-submit="">
            保存
        </button></div>

    </form>

    <div id="page"></div>
</div>
<script src="lib/layui/layui.js" charset="utf-8"></script>
<script src="js/x-layui.js" charset="utf-8"></script>
<script>
    layui.use(['laydate','element','laypage','layer'], function(){
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element();//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        okLoading.close($);
        //以上模块根据需要引入


        var start = {
            min: laydate.now()
            ,max: '2099-06-16 23:59:59'
            ,istoday: false
            ,choose: function(datas){
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };

        var end = {
            min: laydate.now()
            ,max: '2099-06-16 23:59:59'
            ,istoday: false
            ,choose: function(datas){
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };

        document.getElementById('LAY_demorange_s').onclick = function(){
            start.elem = this;
            laydate(start);
        }
        document.getElementById('LAY_demorange_e').onclick = function(){
            end.elem = this
            laydate(end);
        }
    });


</script>

<script>
    var add=document.getElementById('ches');
    var inputs=add.getElementsByTagName('input');

    /*$("allSelect").onclick = function () {
        for(var i=0; i<inputs.length; i++){
            inputs[i].checked = true;
        }
    };*/
    var che=document.getElementById("onclicks");
    che.addEventListener('click',function () {
        for(var i=0; i<inputs.length;i++){
            inputs[i].checked=this.checked;
            //console.log(inputs[i].value);
        }
        //return vel;

    });

    // 注册事件
    /* che.onclick = function(){
         // this.checked  可以得到当前复选框的选中状态，如果是 true 就是选中，如果是 false 就是未选中
         for(var i=0; i< inputs.length; i++){
             inputs[i].checked = this.checked;
         }
     }*/
    // 2、下面的复选框要全部选中，上面的全选按钮才能够全部选中，给下面的所有复选框绑定事件，每次点击，都要循环查看下面下面所有的复选框是否有没选中的，如果有没选中的复选框，那么上面的全选按钮就不选中。
    /*for(var i = 0; i<inputs.length; i++){
        inputs[i].onclick = function(){
             // 设置一个变量来控制按钮是否全部选中
             var flag = true;
             // 每次点击下面的复选框都要检查下面的四个小按钮是否被全部选中。
             /!*for(var i =0; i<inputs.length; i++){
                  if(!inputs[i].checked){
                      flag = false;
                  }
             }*!/
             che.checked = flag;
        }
    }*/

</script>
<script>


</script>
<script>
    layui.use(['element','layer','form'], function(){
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        form = layui.form();
        okLoading.close($);

        //监听提交
        form.on('submit(add)', function updateCustomer() {
            $.post("updateadmin",$('#update_admin').serialize(),function (obj) {
                var i=parseInt(obj);
                if(i>0){
                    alert("修改成功");
                    window.parent.location.reload();
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }else {
                    alert("修改失败");
                }
            });

        });
    });

</script>
</body>
</html>
